<?php

use App\Models\OpenShop\InvestmentPromotion\OpenShopContractTemplateModel;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class AddManagementCostEveryYearToOpenShopContractTemplate extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('open_shop_contract_template', function (Blueprint $table) {
            $table->unsignedInteger('managementCostEveryYear')->default(0)->after('managementCost')->comment('特许权使用费每年');
        });

        if (config("app.env") == "prod" || config('app.env') == 'pre') {
            OpenShopContractTemplateModel::query()->whereIn('id', [2, 3, 4, 5, 6])->update([
                "managementCostEveryYear" => 1200000
            ]);
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('open_shop_contract_template', function (Blueprint $table) {
            $table->dropColumn('managementCostEveryYear');
        });
    }
}
